<!DOCTYPE html>
<html>
  <body>
      <p>This tests that when nodes are foster-parented after being adopted into another document,
          they are adopted back into the ownerDocument of their foster parent. </p>
      <table>
          <tr>
<script>
if (window.testRunner)
    testRunner.dumpAsText();

var tr = document.querySelector('tr');
var doc = document.implementation.createHTMLDocument();
doc.adoptNode(tr);
</script>
              <div></div>
          </tr>
      </table>
<script>
var div = document.querySelector('div');
if (div.ownerDocument === div.parentNode.ownerDocument)
    document.body.appendChild(document.createTextNode('PASS.'));
</script>
    </body>
</html>